package com.example.myworkc;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivitySig extends AppCompatActivity {
    private EditText editText1,editText2;
    private Button buttonSig,buttonLogReturn;
    private SharedPreferences sp;
    private SharedPreferences.Editor editor;
    private Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_sig);
        editText1=findViewById(R.id.editTextSig1);
        editText2=findViewById(R.id.editTextSig2);
        buttonLogReturn=findViewById(R.id.buttonLogReturn);
        buttonSig=findViewById(R.id.buttonSig);
        sp=getSharedPreferences("lock", Context.MODE_PRIVATE);//Context.MODE_PRIVATE表示其他文件无法访问这个sp文件
        editor=sp.edit();
        intent = new Intent(MainActivitySig.this,MainActivityLog.class);
        buttonSig.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                editor.putString("id",editText1.getText().toString().trim());
                editor.putString("password",editText2.getText().toString().trim());
                editor.commit();
                Toast.makeText(getApplicationContext(),"注册成功",Toast.LENGTH_LONG).show();

                /*intent.putExtra("id",editText1.getText().toString().trim());
                intent.putExtra("password",editText2.getText().toString().trim());*/
            }
        });
        buttonLogReturn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(intent);
            }
        });
        editText2.setTransformationMethod(new AsteriskPasswordTransformationMethod());//输入的密码不回显
    }
}